package com.cqc.other.juc.producerConsumer.demo4;


import java.util.ArrayList;
import java.util.List;

public class ThreadTest {
    /**
     * https://pzblog.cn/java/concurrent/concurrent-consumer.html
     * 多生产者和消费者的实现思路
     */
    public static void main(String[] args) {
        Container container = new Container();

        List<Thread> list = new ArrayList<Thread>();
        for (int i = 0; i < 6; i++) {
            ConsumerThread consumerThread = new ConsumerThread(container);
            list.add(consumerThread);

            ProducerThread producerThread = new ProducerThread(container, i);
            list.add(producerThread);
        }
        for (Thread thread : list) {
            thread.start();
        }
    }
}
